home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / Vk / VkMeter.z / VkMeter
Encoding:
Text File  |  1998-10-20  |  13.4 KB  |  397 lines

  1.  
  2.  
  3.  
  4. VVVVkkkkMMMMeeeetttteeeerrrr((((3333xxxx))))                                                        VVVVkkkkMMMMeeeetttteeeerrrr((((3333xxxx))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      VkMeter - Display a layered bar graph
  10.  
  11. IIIINNNNHHHHEEEERRRRIIIITTTTSSSS FFFFRRRROOOOMMMM
  12.      VkDoubleBuffer : VkComponent : VkCallbackObject
  13.  
  14. HHHHEEEEAAAADDDDEEEERRRR FFFFIIIILLLLEEEE
  15.      #include <Vk/VkMeter.h>
  16.  
  17. PPPPUUUUBBBBLLLLIIIICCCC PPPPRRRROOOOTTTTOOOOCCCCOOOOLLLL SSSSUUUUMMMMMMMMAAAARRRRYYYY
  18.    CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrr////DDDDeeeessssttttrrrruuuuccccttttoooorrrr
  19.            VkMeter(const char *name, Widget parent);
  20.            virtual void ~VkMeter(void);
  21.  
  22.  
  23.    AAAAddddddddiiiinnnngggg DDDDaaaattttaaaa
  24.            void reset(int range = -1, int units = -1);
  25.            void add(int value, char *color, char *label = NULL);
  26.            void add(int value, Pixel pixel, char *label = NULL);
  27.            void add(int value, int thickness, char *color,
  28.                     char *label = NULL);
  29.            void add(int value, int thickness, Pixel pixel,
  30.                     char *label = NULL);
  31.            void add(int start, int size, int sideValue, int thickness,
  32.                     char *color, char *label = NULL);
  33.            void add(int start, int size, int sideValue, int thickness,
  34.                      Pixel color, char *label = NULL);
  35.  
  36.  
  37.    DDDDrrrraaaawwwwiiiinnnngggg tttthhhheeee MMMMeeeetttteeeerrrr
  38.            void update();
  39.  
  40.  
  41.    GGGGeeeeoooommmmeeeettttrrrryyyy
  42.            void setOrientation();
  43.            void setResizePolicy( unsigned char policy);
  44.  
  45.  
  46. XXXX RRRREEEESSSSOOOOUUUURRRRCCCCEEEESSSS AAAASSSSSSSSOOOOCCCCIIIIAAAATTTTEEEEDDDD WWWWIIIITTTTHHHH TTTTHHHHIIIISSSS CCCCLLLLAAAASSSSSSSS
  47.            orientation,
  48.            colorList,
  49.            autoScale
  50.  
  51.  
  52. CCCCLLLLAAAASSSSSSSS DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  53.           The VkMeter class supports simple compound bar charts. Single or
  54.           multiple data items can be displayed in a double-buffered window.
  55.           The meter can be displayed in vertical or horizontal mode.
  56.  
  57.           The VkMeter class allows one or more integer values to be displayed
  58.           graphically.  Values are added one at a time, and displayed by
  59.           calling an _u_p_d_a_t_e() member function. The range of values displayed
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. VVVVkkkkMMMMeeeetttteeeerrrr((((3333xxxx))))                                                        VVVVkkkkMMMMeeeetttteeeerrrr((((3333xxxx))))
  71.  
  72.  
  73.  
  74.           can be specified by calling the _r_e_s_e_t() member function with a new
  75.           value.  See examples below.
  76.  
  77.  
  78.  
  79. FFFFUUUUNNNNCCCCTTTTIIIIOOOONNNN DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNNSSSS
  80.    VVVVkkkkMMMMeeeetttteeeerrrr(((())))
  81.           VkMeter(const char *name, Widget parent);
  82.  
  83.  
  84.           Initialize an instance of VkMeter.
  85.  
  86.    ~~~~VVVVkkkkMMMMeeeetttteeeerrrr(((())))
  87.           virtual void ~VkMeter(void);
  88.  
  89.  
  90.           Free all memory allocated by an VkMeter object.
  91.  
  92.    rrrreeeesssseeeetttt(((())))
  93.           void reset(int peak = -1, int units = -1);
  94.  
  95.  
  96.           This function clears the values of all currently displayed data and
  97.           optionally sets the peak value to be displayed by the meter. The
  98.           second argument can be used to specify a scale factor to be applied
  99.           to the "width" of the data displayed by the meter. If no values are
  100.           specified, the peak value defaults to 100, and the unit size
  101.           defaults to 1.
  102.  
  103.    aaaadddddddd(((())))
  104.            void add(int value, char *color, char *label = NULL);
  105.            void add(int value, Pixel pixel, char *label = NULL);
  106.            void add(int value, int thickness,
  107.                     char *color, char *label = NULL);
  108.            void add(int value, int thickness,
  109.                      Pixel pixel, char *label = NULL);
  110.  
  111.            void add(int start, int size, int sideValue,
  112.                     int thickness, char *color, char *label = NULL);
  113.            void add(int start, int size, int sideValue,
  114.                     int thickness, Pixel color, char *label = NULL);
  115.  
  116.  
  117.           All forms of this overloaded function add a data item to be
  118.           displayed by the meter. The _v_a_l_u_e argument indicates a value to be
  119.           displayed in the graph. When one of the first four forms of this
  120.           function are used, multiple data items are displayed sequentially.
  121.           For example, if the range is set to 100 (the default) and value of
  122.           10, 20, and 30 are added, the meter will display a bar from 0-10,
  123.           10-30, and 30-60.
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. VVVVkkkkMMMMeeeetttteeeerrrr((((3333xxxx))))                                                        VVVVkkkkMMMMeeeetttteeeerrrr((((3333xxxx))))
  137.  
  138.  
  139.  
  140.           All data items must have an associated color. The color can be
  141.           specified as a pixel value, or as a string. When a string is
  142.           provided, the string is first treated as the name of a resource to
  143.           be looked up and converted to the desired color. If no such resource
  144.           is found, the string is taken to be the name of a color. For
  145.           example, items might be added as follows:
  146.  
  147.  
  148.            add(10, "red")
  149.            add(20, "DataTwoColor");
  150.  
  151.  
  152.  
  153.           The second and third forms of the _a_d_d() function allow a _t_h_i_c_k_n_e_s_s
  154.           to be specified as well. This value controls the width of each item
  155.           in the bar when the bar is vertical and the height when the bar is
  156.           horizontal.
  157.  
  158.           The final two forms of the _a_d_d() function provide the most control
  159.           over the data displayed in the meter. The first and second arguments
  160.           specify the starting point of the data (the bottom, when the meter
  161.           is vertical) and the size. The third and fourth arguments specify a
  162.           starting point and size in the opposite dimension. For example:
  163.  
  164.  
  165.            add(0, 10, 0, 1, "red");
  166.            add(0, 10, 1, 1, "blue");
  167.            add(0, 10, 2, 1, "green");
  168.            add(20, 10, 0, 3, "yellow");
  169.  
  170.  
  171.  
  172.           When the graph is vertical, this produces a display with three
  173.           vertical lines from 0-10, side by side, in red, yellow and green.
  174.           Above these three lines is a space, and a yellow bar starts at 20
  175.           and extends to thirty. This yellow strip is as wide as all three of
  176.           the previous lines. The total width of the displayed graph is equal
  177.           to the sum of the widths times the scale factor specified in the
  178.           call to reset.
  179.  
  180.    uuuuppppddddaaaatttteeee(((())))
  181.            void update();
  182.  
  183.  
  184.           This function causes all values added with the _a_d_d() member function
  185.           to be displayed.
  186.  
  187.    sssseeeettttRRRReeeessssiiiizzzzeeeePPPPoooolllliiiiccccyyyy(((())))
  188.            void setResizePolicy( unsigned char policy )
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. VVVVkkkkMMMMeeeetttteeeerrrr((((3333xxxx))))                                                        VVVVkkkkMMMMeeeetttteeeerrrr((((3333xxxx))))
  203.  
  204.  
  205.  
  206.           This function allows applications to determine the dynamic resize
  207.           policy followed by the meter. Possible values are XmRESIZE_NONE,
  208.           XmRESIZE_GROW, or XmRESIZE_ANY. If the policy is set to
  209.           XmRESIZE_NONE, the meter will never attempt to resize itself. The
  210.           application, or managing widget is in complete control. If the value
  211.           is set to XmRESIZE_GROW, the meter will call _X_t_S_e_t_V_a_l_u_e_s() on the
  212.           widget used to display the meter to attempt to grow as needed. The
  213.           success of the call to _X_t_S_e_t_V_a_l_u_e_s() depends, of course, on the
  214.           parent widget's policy. If The resize policy is set to XmRESIZE_ANY,
  215.           the meter will attempt to resize itself to grow or shrink as needed.
  216.  
  217.           This function is not currently used by the VkMeter class, but is
  218.           used by derived classes.
  219.  
  220.    sssseeeettttTTTTiiiittttlllleeee(((())))
  221.            void setTitle( const char *title )
  222.  
  223.  
  224.           Specifies a title to be displayed by the meter.  This function is
  225.           not currently used by the VkMeter class, but is used by derived
  226.           classes.
  227.  
  228. EEEEXXXXAAAAMMMMPPPPLLLLEEEE
  229.      The following example creates a meter component that displays four
  230.      values.
  231.  
  232.  
  233.            #include <Vk/VkApp.h>
  234.            #include <Vk/VkSimpleWindow.h>
  235.            #include <Vk/VkMeter.h>
  236.            #include <math.h>
  237.  
  238.            class MeterWindow: public VkSimpleWindow {
  239.  
  240.             public:
  241.  
  242.               MeterWindow ( const char *name );
  243.               ~MeterWindow ();
  244.               virtual const char* className();
  245.            };
  246.  
  247.            MeterWindow::~MeterWindow ()
  248.            {
  249.                // Empty
  250.            }
  251.  
  252.            const char* MeterWindow::className()
  253.            {
  254.                  return "MeterWindow";
  255.             }
  256.  
  257.            MeterWindow::MeterWindow(const char *name) :
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. VVVVkkkkMMMMeeeetttteeeerrrr((((3333xxxx))))                                                        VVVVkkkkMMMMeeeetttteeeerrrr((((3333xxxx))))
  269.  
  270.  
  271.  
  272.                     VkSimpleWindow(name)
  273.            {
  274.               VkMeter *meter = new VkMeter("meter",
  275.                                            mainWindowWidget());
  276.  
  277.               meter->reset(100);
  278.               meter->add ((int) (10.0 ), 20, "red"  );
  279.               meter->add( (int) (20.0),  20, "green" );
  280.               meter->add( (int) (30.0 ), 20, "blue" );
  281.               meter->add( (int) (40.0),  20, "orange");
  282.  
  283.               meter->update( );
  284.  
  285.               meter->show();
  286.  
  287.               addView( meter);
  288.            }
  289.  
  290.            void main ( int argc, char **argv )
  291.            {
  292.               VkApp   *meterApp = new VkApp("MeterApp",
  293.                                              &argc, argv);
  294.  
  295.               MeterWindow  *meterWin = new MeterWindow("meter");
  296.               meterWin->show();
  297.               meterApp->run();
  298.            }
  299.  
  300.  
  301.  
  302. IIIINNNNHHHHEEEERRRRIIIITTTTEEEEDDDD MMMMEEEEMMMMBBBBEEEERRRR FFFFUUUUNNNNCCCCTTTTIIIIOOOONNNNSSSS
  303.    IIIInnnnhhhheeeerrrriiiitttteeeedddd ffffrrrroooommmm VVVVkkkkDDDDoooouuuubbbblllleeeeBBBBuuuuffffffffeeeerrrr
  304.           _canvas, _width,  _height
  305.  
  306.  
  307.    IIIInnnnhhhheeeerrrriiiitttteeeedddd ffffrrrroooommmm VVVVkkkkCCCCoooommmmppppoooonnnneeeennnntttt
  308.           installDestroyHandler(), removeDestroyHandler(), widgetDestroyed(),
  309.           setDefaultResources(), getResources(), manage(), unmanage(),
  310.           baseWidget(), okToQuit(), _name, _baseWidget, _w, deleteCallback
  311.  
  312.  
  313.    IIIInnnnhhhheeeerrrriiiitttteeeedddd ffffrrrroooommmm VVVVkkkkCCCCaaaallllllllbbbbaaaacccckkkkOOOObbbbjjjjeeeecccctttt
  314.           callCallbacks(), addCallback(), removeCallback(),
  315.           removeAllCallbacks()
  316.  
  317.  
  318. KKKKNNNNOOOOWWWWNNNN DDDDEEEERRRRIIIIVVVVEEEEDDDD CCCCLLLLAAAASSSSSSSSEEEESSSS
  319.      VkPie
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. VVVVkkkkMMMMeeeetttteeeerrrr((((3333xxxx))))                                                        VVVVkkkkMMMMeeeetttteeeerrrr((((3333xxxx))))
  335.  
  336.  
  337.  
  338. CLASSES USED BY THIS CLASS
  339.      VkApp
  340.  
  341. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  342.      VkDoubleBuffer, VkComponent, VkApp, VkPie
  343.      _V_i_e_w_K_i_t _P_r_o_g_r_a_m_m_e_r'_s _G_u_i_d_e
  344.      _T_h_e _X _W_i_n_d_o_w _S_y_s_t_e_m, DEC Press, Bob Sheifler and Jim Gettys
  345.      _T_h_e _X _W_i_n_d_o_w _S_y_s_t_e_m _T_o_o_l_k_i_t, DEC Press, Paul Asente and Ralph Swick
  346.      _T_h_e _O_S_F/_M_o_t_i_f _P_r_o_g_r_a_m_m_e_r_s _R_e_f_e_r_e_n_c_e, Prentice Hall, OSF
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.